<extend name="public:template"/>

<block name="title">新增角色</block>

<block name="content">
    <div class="wrap-page">
        <div id="pageMemberInfo" class="page-content">
            <include file="public:subtabs"/>
            <form class="form default-style" role="form" action="{:u('backend/admin_role/add')}" method="post">

                <div id="tabSwitchProduct" class="tab-switch">

                    <!--选项卡-->
                    <div class="tabs-title clearfix">
                        <ul>
                            <li class="current"><a data-id="tab-basic" href="javascript:;">基本信息</a></li>
                        </ul>
                    </div>
                    <!--选项卡-->

                    <!--编辑区域-->
                    <div class="tab-content">
                        <div id="tab-basic-content" class="tab-content-inner">
                            <div id="boxBasicInfo" class="box">
                                <div class="box-content">

                                    <dl class="clearfix">
                                        <dt><label>新角色：</label></dt>
                                        <dd>
                                            <div class="item-field clearfix">
                                                <input id="name" placeholder="请输入新角色" class="textfield" type="text" value="" name="name"  autocomplete="off"/>
                                            </div>
                                        </dd>
                                    </dl>


                                    <dl class="clearfix">
                                        <dt><label>状态：</label></dt>
                                        <dd>
                                            <div class="item-field clearfix">
                                                <div class="radio-layout-h clearfix">
                                                    <div class="radio-item">
                                                        <span class="radio-field"><input class="radio" value="1" name="status" type="radio" checked /></span>
                                                        <span class="radio-text"><label >启用</label></span>
                                                    </div>
                                                    <div class="radio-item">
                                                        <span class="radio-field"><input class="radio"  value="0" name="status" type="radio" /></span>
                                                        <span class="radio-text"><label >禁用</label></span>
                                                    </div>
                                                </div>
                                            </div>
                                        </dd>
                                    </dl>

                                </div>
                            </div>
                        </div>
                    </div>
                    <!--编辑区域END-->
                </div>
                <div class="page-buttons clearfix">
                    <div class="fl-l">
                        <button type="button" class="button button-blue" id="save">保存</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
</block>
<block name="script">
    <script>
        $(document).ready(function(){
            $('#save').click(function(){
                var name     = $.trim($('#name').val());


                if(!name)
                {
                    $('#name').val('').focus();
                    layer.tips('请输入新角色', '#name', {
                        tips: [2, '#009f95'],
                        time: 3000
                    });
                    return false;
                }

                //数据验证
                $.ajax({
                    type: "POST",
                    url: $('.form').attr('action'),
                    data: $('.form').serialize(),
                    dataType: "json",
                    success:function(data){
                        if(data.status)
                        {
                            layer.msg(data.msg,{icon: 1,time:2000, shade: [0.1, '#ccc']},function(){
                                window.location.href="{:u('backend/admin_role/index')}";
                            })
                        } else {
                            layer.msg(data.msg,{icon: 2,time:2000, shade: [0.1, '#ccc']})
                        }

                    }
                });
                return false;
            });
        });
    </script>
</block>